var app = getApp(),
  a = app.requirejs('core');
  var loading=false;
Page({
    data: {
        show:false,
        status: 1,
        first_count: 0,
        second_count: 0,
        third_count: 0,
        list: [],
        loaded: false,
        page: 1
     
    },
    onLoad: function(t) {
       a.ReName(t.title);
       this.setData({
         share_setting: app.getCache('shareSetting')
       })
      this.getlist();
    },
  getlist: function () {
    if(loading){
      return;
    }
    loading=true;
    var that = this,
      page = that.data.page;
    a.get('Distribe/myteam', {
        page:page,
        uid:app.getCache('userinfo').uid != undefined ? app.getCache('userinfo').uid : 0,
        status:that.data.status
    }, function (t) {
      loading=false;
      if (t.code == 0) {
        that.setData({
          list: that.data.list.concat(t.info.list),
          first_count: t.info.first,
          second_count: t.info.second,
          third_count: t.info.third,
          page: t.info.list.length == 0 ? that.data.page : (that.data.page+1),
          loaded: t.info.list.length < 10 ? true : false,
          show: true
        })
      } else {
        a.alert(t.msg);
      }
    })
  },
  select:function(e){
    var that=this,
    i=a.pdata(e).status;
    that.setData({
      page:1,
      list:[],
      loaded:false,
      status:i
    })
    this.getlist()
  },

  /**
    * 下拉刷新
    */
  onPullDownRefresh: function () {
    this.setData({
      list: [],
      page: 1,
      loaded: false
    })
    this.getlist()
    wx.stopPullDownRefresh();
  },
  /**
   *上拉加载
   */
  onReachBottom: function () {
    console.log('加载更多')
    this.data.loaded || this.getlist()
  },
});